package com.dgw.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @program: spring-boot-web-restfulcrud
 * @description: spring mvc 高级特性
 * @author: Mr.Dai
 * @create: 2019-12-01 18:04
 **/
@ApiIgnore
@Controller
public class TestController {

    @ModelAttribute
    public void before(Model model){
        System.out.println("--->before");
        model.addAttribute("person1","nihao");
    }

    @GetMapping("/model")
    public String model1(Model model){
        model.addAttribute("person2","world");
        System.out.println("------>model");
        return "redirect:/model2";
    }

    @GetMapping("/model2")
    public String model2(Model model){
        System.out.println("---->model2");
        model.addAttribute("person3","lang");
        return "model";
    }
}
